﻿using System;
using System.Xml;
using System.Data;
using System.IO;

namespace SBPweb.MediaCenter.Modules.Customizer.Data
{
    public class ProfilesDataSource : Common.Data.DataSourceBase<Profiles>
    {
        public ProfilesDataSource(string sourceXml)
            : base(sourceXml, new Profiles())
        {
        }

        public Profiles.ProfileRow[] Profile
        {
            get
            {
                return Array.ConvertAll<DataRow, Profiles.ProfileRow>(base.pDataSet.Profile.Select(PROFILE_FILTER_EXPRESSION, PROFILE_SORT_EXPRESSION), ConvertTo);
            }
        }

        public Profiles.ProfileRow ConvertTo(DataRow dataRow)
        {
            return (Profiles.ProfileRow)dataRow;
        }
        /*
        private const string PROFILE_FILTER_EXPRESSION = null;
        private const string PROFILE_SORT_EXPRESSION = "Name";

        protected string pXml;
        protected Profiles pProfilesDataSet;

        public ProfilesDataSource(string sourceXml)
        {
            FileInfo fI = new FileInfo(sourceXml);
            if (!fI.Exists)
            {
                throw new ArgumentException(sourceXml);
            }

            pXml = fI.FullName;
            pProfilesDataSet = new Profiles();

            pProfilesDataSet.ReadXml(pXml);
        }

        

        public void Save()
        {
            pProfilesDataSet.WriteXml(pXml);
        }

        
        */
    }
}
